<?php 
/*include "securimage.php"; 
if(isset($_POST['submit'])) //This code will be executed only when the user click the submit
{
 include_once "dbconnect.php"; // This makes easy to change the db username, password etc
  $img = new Securimage();
  $valid = $img->check($_POST['code']);
}*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<link rel="stylesheet" type="text/css" title="My style" media="screen" href="css/style.css" />
<style type="text/css">
#checkEmail {
  margin-left: auto;
  margin-right: auto;
  margin-top: 40px;
  padding: 20px;
  width: 400px;
  height: 50px;
  background: #C0C0C0;
  -moz-border-radius: 20px;
  }
#linkback {
  margin-left: auto;
  margin-right: auto;
  margin-top: 40px;
  padding: 20px;
  width: 200px;
  height: 20px;
  background: #C0C0C0;
  -moz-border-radius: 20px;
  }
</style>
<title> ..:: mukt.in | Talk , Demo ,Projects Registration ::..</title>
<script type="text/javascript" src="js/talkregistration.js"></script>
</head>
<body>
<?php
/*
if(isset($_POST['submit'])) {
  if($valid == true) 
    { }
   else {
    echo "<center><div id='checkEmail'>Sorry, the code you entered was invalid.  <a href='registration.php'>Go back</a> to try again.</div></center>";
    die;
  }
}*/
?>
<?php
// User may turn off Java script ,hence its better to do form validation with php i.e at serverside also .
include_once "dbconnect.php";
if(isset($_POST['submit'])) //This code will be executed only when the user click the submit 
{

//no need to change the db name , password in all the files just change here .

	//This is block is to avoid sql injection 
//	$loginname = mysql_real_escape_string($_POST['loginname']);
//	$password = mysql_real_escape_string($_POST['password']); password field has been removed
	$firstname = mysql_real_escape_string($_POST['firstname']);
	$lastname = mysql_real_escape_string($_POST['lastname']);
	$email = mysql_real_escape_string($_POST['email']);
	$role = mysql_real_escape_string($_POST['role']);
	$organization = mysql_real_escape_string($_POST['organization']);
	$city = mysql_real_escape_string($_POST['city']); 
	$state = mysql_real_escape_string($_POST['state']); 
	$activationcode = strval(mt_rand());
	$status = 0 ; // its mean the user has not clicked that activation link

	$sessiontype = mysql_real_escape_string($_POST['sessiontype']);
	$sessiontitle = mysql_real_escape_string($_POST['sessiontitle']);
	$sessiondescription = mysql_real_escape_string($_POST['sessiondescription']);
	$sessionday = mysql_real_escape_string($_POST['sessionday']);
	$sessionduration = mysql_real_escape_string($_POST['sessionduration']);
	$speakerstatus = mysql_real_escape_string($_POST['speakerstatus']);
	$sessionstatus = 0; 
	$slidestatus = 0;
	$type=2;		//telling us that this is speaker registration.

	//To avoid null values

	if (($firstname == "") || ($lastname == "") || ($email == "") || ($organization == "") || ($city == "") || ($state ==  "") || ($role=="") || ($sessiontype == "") || ($sessiontitle == "")  || ($sessiondescription == "") || ($speakerstatus == "") || ($sessionday == "") ||($sessionduration ==""))
	{
		echo "FirstName: $firstname<br/>";
		echo "LastName: $lastname<br/>";
		echo "Email: $email<br/>";
		echo "Organization: $organization<br/>";
		echo "City: $city<br/>";
		echo "State: $state<br/>";
		echo "Role: $role<br/>";
		echo "SessionType: $sessiontype<br/>";
		echo "SessionTitle: $sessiontitle<br/>";
		echo "SessionDescription: $sessiondescription<br/>";
		echo "SpeakerStatus: $speakerstatus<br/>";
		echo "SessionDay: $sessionday<br/>";
		echo "SessionDuration: $sessionduration<br/>";
		die("<div id='checkEmail'>please fill all the fields <a href='javascript:history.go(-1)'>Go back</a></div>");
	}

	function check_email_address($email) 
	{
		// First, we check that there's one @ symbol, and that the lengths are right
		if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) 
		// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
			return false;
	
// Split it into sections to make life easier
		$email_array = explode("@", $email);
		$local_array = explode(".", $email_array[0]);
		for ($i = 0; $i < sizeof($local_array); $i++) 
			if(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) 
				return false;

		if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) 
		{ // Check if domain is IP. If not, it should be valid domain name
			$domain_array = explode(".", $email_array[1]);
			if (sizeof($domain_array) < 2) 
				return false; // Not enough parts to domain
		}
	
		for ($i = 0; $i < sizeof($domain_array); $i++) 
			if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) 
				return false;

		return true;
	}
		
	if(!check_email_address($email)) 
		die("<div id='checkEmail'> " . $email . " is a not a valid email address.<a href='javascript:history.go(-1)'>Go back and Try Again</a>");

	//This block is to avoid duplicate entries 
	$query1 = "SELECT email FROM mukt_participants WHERE email='$email'"; 
	//email is the best thing to identify duplicate users
	$user_exist = mysql_query($query1) or die(mysql_error());
	if($user_exist && mysql_num_rows($user_exist) >= 1) 
		die("<div id='checkEmail' align='center'>This email id has already been registered. <br /> Please use another one. <br /><a href='javascript:history.go(-1)'>Go back</a>");
	  
    
	//For email address format vaildation 
		
	$query2 =	"insert into mukt_participants (firstname, lastname, email,city,state,role,activationcode,status,sessiontype ,sessiontitle ,sessiondescription ,sessionday ,sessionduration ,speakerstatus ,sessionstatus ,slidestatus) value ('$firstname','$lastname','$email','$city','$state','$role','$activationcode','$status','$sessiontype','$sessiontitle','$sessiondescription','$sessionday','$sessionduration' ,'$speakerstatus','$sessionstatus','$slidestatus')" ;
	
	mysql_query($query2) or die('insertion error ' . mysql_error());

	$headers = 'From: muktin@unixpod.com' . "\r\n" .
    'Reply-To: muktin@unixpod.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

//dont forget to change the url in the MSG 
		$message = <<<MSG
	
	
	Hi $firstname,
	
	Thank you for registering at mukt.in 2008.Please Send your Presentation slides to krish@mukt.in with the subject line "mukt.in2008 talk slide" as soon as possible
	
	This is your confirmation link, please click on it to complete your registration.

	http://mukt.in/test/reg_confirm.php?activationcode=$activationcode&email=$email&type=$type
	
	Note : If the hyperlink doesn't work, please Copy and paste the url in the browser address bar.

	Hints :
	--------------------
	1.This is an open source event , your talk ,demo,project must be releavant to open source.
	2.Talk about open source technologies , Dont talk about your company or product this is not a place for this.
	3.Mukt.in may not provide Food ,accomadation etc for all the visitor .  
	
	Thanks,
	mukt.in Team
MSG;

		$message = wordwrap($message, 70);
		mail( $email, "mukt.in Activation Email", $message, $headers);
		echo "<div id='checkEmail' align='center'>An activation link has been sent to <b>$email</b> <br />We request you to confirm activation.<br /><br />
		Please send your Presentation slides to <a href=\"mailto:krish@mukt.in?subject=mukt.in2008%20talk%20slide\">krish</a> as soon as possible.</div>";
		echo "<br/>";
		echo "<div id='linkback' align='center'><a href='index.php'>Back to Home Page</a></div>";
		
	
}

if (!isset($_POST['submit'])) {
?>
<div id="container">
<div id="header">
<br /><b></b>
</div>
<div id="leftColumn">
<div id="menucontainer">
<ul id="hex">
<li class="p1"><a class="inner" href="participate.php"><b></b><span>Participate</span><em></em></a></li>
<li><a href="sponsors.php"><b></b><span>Sponsors</span><em></em></a></li>
<li class="p2"><a href="http://groups.google.com/group/mukt/feed/rss_v2_0_msgs.xml"><b></b><span>Feeds</span><em></em></a></li>
<li class="p2"><a href="index.php"><b></b><span>About</span><em></em></a></li>
<li class="p2"><a href="studio.php"><b></b><span>Studio</span><em></em></a></li>
<li class="p1 p2"><a href="chat.php"><b></b><span>Chat</span><em></em></a></li>
<li class="p2"><a href="contact.php"><b></b><span>Contact</span><em></em></a></li>
</ul>
</div>
</div>
<div id="rightColumn">
<p align="center" id="numUsers">
<br />
<?php 
include_once "dbconnect.php";
$num=mysql_num_rows(mysql_query("select * from mukt_participants")) ;
echo "Registered Users: <span class='green'>$num</span>";
?> 
</p>
<br /><br />

<p align="center"> <b>All the Field must be filled </b></p>
<form method="post" action="participants_registration.php" name="form" id="form" onsubmit="validate(this) ; return false;">
<table cellspacing="20" cellpadding="10"> 


<!--dont change the names used here becaues its used for JS validation !-->
<tr>
<td>First Name: </td>
<td><input type="text" name="firstname" id="firstname" /></td>
<td><img src="images/info.png" title="Enter your first name here" alt="Enter your first name here" /></td>
</tr>
 
<tr>
<td>Last Name: </td>
<td><input type="text" name="lastname" id="lastname" /></td>
<td><img src="images/info.png" title="Enter your last name here" alt="Enter your last name here" /></td>
</tr>

<tr>
<td>Email: </td>
<td><input type="text" name="email" id="email" /></td>
<td><img src="images/info.png" title="Enter your e-mail address here" alt="Enter your e-mail address here" /></td>
</tr>
 
<tr>
<td>Role: </td>
<td>
<input type="radio" name="role" value="student" />&nbsp; Student &nbsp;
<input type="radio" name="role" value="professional" />&nbsp; Professional &nbsp;
</td>
<td><img src="images/info.png" title="Select your designation " alt="Select your designation" /></td>
</tr>

<tr>
<td></td>
<td><input type="radio" name="role" value="Other" />&nbsp; Other &nbsp;</td>
</tr>

<!--
<td><input type=""
<select name="role" id="role">
<option value="">Select</option>
<option value="student">Student</option>
<option value="professional">Professional</option>
<option value="other">Other</option>
</select>
</td>
<td><img src="images/info.png" title="Select your designation " alt="Select your designation" /></td>
</tr>!-->
 
<tr>
<td>Organization/College: </td>
<td><input type="text" name="organization" id="organization" /></td>
<td><img src="images/info.png" title="Enter your Organization and University/college name here" alt="Enter your Organization and University / college name here" /></td>
</tr>
 
<tr><td>State: </td><td>
<select name="state" id="state">
<option value="">Select
</option><option value="Andaman and Nicobar Islands">Andaman and Nicobar Islands
</option><option value="Andhra Pradesh">Andhra Pradesh 
</option><option value="Arunachal Pradesh">Arunachal Pradesh
</option><option value="Assam">Assam
</option><option value="Bihar">Bihar
</option><option value="Chandigarh">Chandigarh
</option><option value="Chhattisgarh">Chhattisgarh
</option><option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli
</option><option value="Daman and Diu">Daman and Diu
</option><option value="Delhi">Delhi
</option><option value="Goa">Goa
</option><option value="Gujarat">Gujarat
</option><option value="Haryana">Haryana
</option><option value="Himachal Pradesh">Himachal Pradesh
</option><option value="Jammu and Kashmir">Jammu and Kashmir
</option><option value="Jharkhand">Jharkhand
</option><option value="Karnataka">Karnataka
</option><option value="Kerala">Kerala
</option><option value="Lakshadweep">Lakshadweep 
</option><option value="Madhya Pradesh">Madhya Pradesh
</option><option value="Maharashtra">Maharashtra
</option><option value="Manipur[1]">Manipur[1]
</option><option value="Meghalaya">Meghalaya
</option><option value="Mizoram">Mizoram
</option><option value="Nagaland">Nagaland
</option><option value="Orissa">Orissa
</option><option value="Pondicherry">Pondicherry
</option><option value="Punjab">Punjab
</option><option value="Rajasthan">Rajasthan
</option><option value="Sikkim">Sikkim
</option><option value="Tamil Nadu">Tamil Nadu
</option><option value="Tripura">Tripura
</option><option value="Uttar Pradesh">Uttar Pradesh
</option><option value="Uttarakhand">Uttarakhand
</option><option value="West Bengal">West Bengal
</option><option value="other">Other
 
</option>
</select>
</td>
 
<td><img src="images/info.png" title="Select Your state " alt="Select your state" /></td>
</tr>
 
<tr><td>City: </td><td><input type="text" name="city" id="city" /></td>
<td><img src="images/info.png" title="Select Your City " alt="Select your city" /></td></tr>

<tr>
<td>Session Type :</td>	
<td><input type="radio" name="sessiontype"  value="talk" /> &nbsp; Talk &nbsp; <input type="radio" name="sessiontype"  value="demo" >&nbsp; Demo &nbsp; <input type="radio" name="sessiontype"  value="project" > &nbsp; Project &nbsp;</td>
<td><img src="images/info.png" title="Select your session type" alt="Select your session type" /></td>
</tr>
<!--name=sessiontype must be common so than user will be able to select either talk or demo or project .!-->

<tr>
<td>Session Title :</td>
<td><input type="text" id="sessiontitle" name="sessiontitle" /></td>
<td><img src="images/info.png" title="Enter the title of your session here" alt="Enter the title of your session here" /></td>
</tr>

<tr>
<td>Session Description : </td>
<td>
<textarea id="sessiondescription" name="sessiondescription" rows="5" cols="27"></textarea>
</td>
<td><img src="images/info.png" title="Describe about your session within 100 word" alt="Describe about your session within 100 word" /></td>
</tr>

<tr>
<td>Session duration :</td>
<td><input type="text" size="4" name="sessionduration" id="sessionduration" />  in minutes</td>

<td><img src="images/info.png" title="Enter the approximate time duration that your session may take" alt="Enter the approximate time duration that your session may take"/></td>
</tr>


<tr>
<td>Preferred Day :</td>
<td><input type="radio" name="sessionday" id="sessionday" value="August 1" />&nbsp; August 1 &nbsp; &nbsp;
<input type="radio" name="sessionday" id="sessionday" value="August 2 " />&nbsp; August 2 &nbsp; &nbsp;
</td>
<td><img src="images/info.png" title="Muktin2008 is three day event ,Select the day which is more preferrable for you " alt="Muktin2008 is three day event ,Select the day which is more preferrable for you "/></td>
</tr>

<tr>
<td></td>
<td><input type="radio" name="sessionday" id="sessionday" value="August 3" />&nbsp; August 3 &nbsp; &nbsp;
<input type="radio" name="sessionday" id="sessionday" value="Any Day" />&nbsp; Any Day &nbsp; &nbsp; </td>
</tr>

<tr>
<td>Speaker Status :</td>
<td><input type="radio" name="speakerstatus" id="speakerstatus" value="beginner" />&nbsp; Beginner &nbsp;
<input type="radio" name="speakerstatus" id="speakerstatus" value="intermediate" />&nbsp;
Intermediate &nbsp;

</td></tr>

<tr>
<td></td>
<td><input type="radio" name="speakerstatus" id="speakerstatus" value="expert" />&nbsp;
Expert &nbsp;</td>
</tr>

<!--
<tr><td></td>
<td><img src="securimage_show.php?sid=<?php //echo md5(uniqid(time())); ?>" alt="Security Code" /><br /></td></tr>
<tr><td>Enter the security code as shown above in the image: </td>
<td><input type="text" name="code" id="code" /><br /></td></tr> -->
 
<tr><td><!-- <input type="reset" title="click here to clear the from" /> --></td>
<td><br /><input type="submit" name="submit" value="Yes, I want to Attend mukt.in 2008" title="click here to submit the form" /></td></tr> 
</table>
</form>
</div>

<div id="footer">
<div id="loginbox">
    <p>
    <?php if (isset($_SESSION['login'])) { ?>
    You are logged in as: <a href="profile.php"><?php echo $_SESSION['uname']?></a> [<a href="logout.php">Logout</a>]
    <?php } else { ?>
    <a href="login.php">[Login]</a>
    <?php } ?>
    </p>
</div>
<p>Thanks to Svein Erik Storkaas. CSS Hack by krish.</p>
</div>
</div>

<?php } //Endif not to display form if user has submitted data ?>
</body>
</html>
